package com.test;

/**
 * Created with IntelliJ IDEA.
 * User: lxf
 * Date: 2017/5/26
 * Time: 17:45
 * To change this template use Editor | File and Code Templates.
 */
public class ThreadDemo extends Thread {

    @Override
    public void run() {
        try {
            testSynMethod();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    String lockObj = "lockMe";

    public void testSynMethod() throws InterruptedException {
        synchronized (lockObj) {
            System.out.println(Thread.currentThread().getName());
            Thread.currentThread().sleep(2000);
            throw new RuntimeException("i am an Exception");
        }

//        Thread.sleep(2000);

    }
}
